const registerRouter = require('./backend/router');

module.exports = {
	outputDir: 'dist',
	productionSourceMap: false,
	lintOnSave: false,
	publicPath: process.env.NODE_ENV === 'production' ? '/chicken-music/' : '/',
	devServer: {
		before(app) {
			registerRouter(app)
		}
	},
	configureWebpack: (config) => {
		if (process.env.npm_config_report) {
			const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
			config.plugins.push(new BundleAnalyzerPlugin())
		}
		if (process.env.NODE_ENV === 'production') {
			config.mode = 'production'
			config['performance'] = {
				maxEntrypointSize: 10000000,
				maxAssetSize: 30000000,
				assetFilter: function(assetFilename) {
					return assetFilename.endsWith('.js');
				}
			}
		}
	}
}
